package com.k.note;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.util.LruCache;
import android.view.MotionEvent;
import android.widget.LinearLayout;
import android.widget.Scroller;

/**
 * Created by mac_wk on 14-11-26.
 */
public class SwapLin extends LinearLayout {
    Scroller scroller;
    private boolean isOpen = false;

    public boolean isOpen() {
        return isOpen;
    }

    public void setOpen(boolean isOpen) {
        this.isOpen = isOpen;
    }

    public SwapLin(Context context) {
        super(context);
        init();
    }

    private void init() {
        scroller = new Scroller(getContext());

    }
    @Override
    public void computeScroll() {
        if (scroller.computeScrollOffset()) {
            scrollTo(scroller.getCurrX(), 0);
            postInvalidate();
        }
    }
    public void beginScroll(){
        scroller.startScroll(0, 0, -500, 0, 1000);
        invalidate();
    }

    public SwapLin(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public SwapLin(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    @TargetApi(Build.VERSION_CODES.L)
    public SwapLin(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    int d_x;
    int d_y;
    public void left(int x)
    {
        scrollTo(x,getScrollY());
    }
}

